#include "TeacherStudentScore.h"
#include "ui_TeacherStudentScore.h"
#include <QDebug>
TeacherStudentScore::TeacherStudentScore(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::TeacherStudentScore)
{
    ui->setupUi(this);


    // 设置表格表头
    QStringList headers;
    headers << "姓名" << "第一阶段成绩(1)" << "第一阶段成绩(2)" << "第一阶段成绩(3)" << "第一阶段成绩(4)"
            << "第二阶段成绩(1)" << "第二阶段成绩(2)" << "第二阶段成绩(3)" << "第三阶段成绩(1)" << "第三阶段成绩(2)" << "第三阶段成绩(3)";
    ui->tableWidget->setColumnCount(11);
    ui->tableWidget->setHorizontalHeaderLabels(headers);
    ui->tableWidget->setRowCount(0);
    ui->tableWidget->verticalHeader()->setVisible(false);

    // 设置表头自动拉伸
    ui->tableWidget->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);

    // 设置表格内的字体颜色为白色
    ui->tableWidget->resizeColumnsToContents();  // 自动调整所有列的宽度以适应内容


    // 设置表格内的字体颜色为白色
    for (int row = 0; row < ui->tableWidget->rowCount(); ++row)
    {
        for (int col = 0; col < ui->tableWidget->columnCount(); ++col)
        {
            QTableWidgetItem* item = ui->tableWidget->item(row, col);

            if (item)
            {
                item->setForeground(QBrush(QColor(255, 255, 255)));
            }
        }
    }

    ui->tableWidget->resizeColumnsToContents();  // 自动调整所有列的宽度以适应内容

    // 设置label样式
    ui->image_label->setPixmap(QPixmap(":/TeacherImage/Score.png"));
    ui->image_label->setStyleSheet("background: transparent;");
    ui->image_label->setFixedSize(80, 80);  // 设置 QLabel 固定为 100x100 大小
    ui->image_label->setScaledContents(true);
    ui->text_label->setStyleSheet("color:white;");

    // 设置背景图片
    this->setStyleSheet("background-image: url(:/TeacherImage/bk3.jpg);");
}

TeacherStudentScore::~TeacherStudentScore()
{
    delete ui;
}

void TeacherStudentScore::setStudentName(const QString &name)
{
    studentName = name;
        qDebug() << "学生姓名：" << studentName;  // 输出学生姓名到调试日志
}


